package com.wolfking.demo.converter;

import com.wolfking.converter.spring.ConverterInterface;
import com.wolfking.converter.spring.ConverterMethod;
import com.wolfking.converter.spring.CustomConverter;
import com.wolfking.converter.spring.SqlParam;
import com.wolfking.converter.transform.extend.StringSplitListTransform;

import java.util.List;

@ConverterInterface
public interface DemoInterface {

    @CustomConverter(name = "jobs", transform = StringSplitListTransform.class,constructArg = "#")
    @ConverterMethod(sql = "select 'ximenqing' as `name`,'女' as `sex.sex`,'100' as `sex.age`,1000 as `salary`,now() as `birth`,'a#b#c#d,e' as `jobs`,\n" +
            "                'chars' as chars,'bytes' as bytes ,'truE' as `b` from student limit 1")
    A queryOne();

    @CustomConverter(name = "jobs", transform = StringSplitListTransform.class)
    @ConverterMethod(sql = "select 'ximenqing' as `name`,'女' as `sex.sex`,'100' as `sex.age`,1000 as `salary`,now() as `birth`,'a,b,c,d,e' as `jobs`,\n" +
            "                'chars' as chars,'bytes' as bytes ,'truE' as `b` from student")
    List<A> queryList();


    @CustomConverter(name = "jobs", transform = StringSplitListTransform.class)
    @ConverterMethod(sql = "select ? as `name`,? as `sex.sex`,'100' as `sex.age`,1000 as `salary`,now() as `birth`,? as `jobs`,\n" +
            "                'chars' as chars,'bytes' as bytes ,'truE' as `b` from student limit 1")
    A queryOneArgs(String name, String sex, String jobs);

    @CustomConverter(name = "jobs", transform = StringSplitListTransform.class, constructArg = "#")
    @ConverterMethod(sql = "select :name as `name`,#{name} as `sex.sex`,'100' as `sex.age`,1000 as `salary`,now() as `birth`,#{name} as `jobs`,\n" +
            "                'chars' as chars,'bytes' as bytes ,'truE' as `b` from student limit 1")
    A queryOneArgsParma(@SqlParam("name") String name);

    @CustomConverter(name = "jobs", transform = StringSplitListTransform.class)
    @ConverterMethod(sql = "select :name as `name`,:sex as `sex.sex`,'100' as `sex.age`,1000 as `salary`,now() as `birth`,:jobs as `jobs`,\n" +
            "                :sex as chars,:jobs as bytes ,'truE' as `b` from student limit 1")
    A queryOneArgsParma2(@SqlParam("name") String name, @SqlParam("sex") String sex, @SqlParam("jobs") String jobs);

    @CustomConverter(name = "jobs", transform = StringSplitListTransform.class)
    @ConverterMethod(sql = "select 'ximenqing' as `name`,'女' as `sex.sex`,'100' as `sex.age`,1000 as `salary`,now() as `birth`,'a,b,c,d,e' as `jobs`,\n" +
            "                'chars' as chars,'bytes' as bytes ,'truE' as `b` from student where id in (:ids)")
    List<A> queryListIds(@SqlParam("ids") List<Long> ids);

}
